/*HM_ScriptNS4.js
* HierMenus Version 5
* Copyright (c) 2003 Peter Belesis. All Rights Reserved.
* Originally published and documented at http://www.hiermenuscentral.com/
* Available solely from Jupitermedia Corporation under exclusive license.
* Contact hiermenu@internet.com for more information.
*/

HM_Version="5.1";

// 5.1 
HM_f_NavOtherOnUnload = (window.onunload) ? window.onunload : function() {return true;};
function HM_f_NavUnloadHandler() {
        HM_IsReloading = true;
        return HM_f_NavOtherOnUnload();
}               
window.onunload = HM_f_NavUnloadHandler;      

HM_a_Parameters = [
	["MenuWidth",          150,		"number"],
	["FontFamily",         "Arial,sans-serif"],
	["FontSize",           10,		"number"],
	["FontBold",           false,	"boolean"],
	["FontItalic",         false,	"boolean"],
	["FontColor",          "black"],
	["FontColorOver",      "white"],
	["BGColor",            "white"],
	["BGColorOver",        "black"],
	["ItemPadding",        3,		"number"],
	["BorderWidth",        2,		"number"],
	["BorderColor",        "red"],
	["SeparatorSize",      1,		"number"],
	["ImageDir",           HM_ScriptDir],
	["ImageSrc",           "HM_More_black_right.gif", "image"],
	["ImageSrcOver",       "", "image"],
	["ImageSrcLeft",       "HM_More_black_left.gif", "image"],
	["ImageSrcLeftOver",   "", "image"],
	["ImageSize",          5,		"number"],
	["ImageHorizSpace",    0,		"number"],
	["ImageVertSpace",     0,		"number"],
	["KeepHilite",         false,	"boolean"],
	["ClickStart",         false,	"boolean"],
	["ClickKill",          true,	"boolean"],
	["ChildOverlap",       20,		"number"],
	["ChildOffset",        10,		"number"],
	["ChildPerCentOver",   null,	"number"],
	["TopSecondsVisible",  .5,		"number"],
	["ChildSecondsVisible",.3,		"number"],
	["StatusDisplayBuild", 1,		"boolean"],
	["StatusDisplayLink",  1,		"boolean"],
	["UponDisplay",        null,	"delayed"],
	["UponHide",           null,	"delayed"],
	["RightToLeft",        false,	"boolean"],
	["CreateTopOnly",      0,		"boolean"],
	["ShowLinkCursor",     false,	"boolean"],
	["NSFontOver",         true,	"boolean"],
	["ScrollEnabled",      false,	"boolean"],
	["ScrollOver",         false,	"boolean"],
	["ScrollInterval",     20,	"number"],
	["ScrollBarHeight",    16,      "number"],
	["ScrollBarColor",     "lightgrey"],
	["ScrollImgSrcTop",    "HM_More_black_top.gif", "image"],
	["ScrollImgSrcBot",    "HM_More_black_bot.gif", "image"],
	["ScrollImgWidth",     9,       "number"],
	["ScrollImgHeight",    5,       "number"],
	["ScrollBothBars",     false,   "boolean"],
	["ScrollHeightMin",    30,      "number"],
	["FramesEnabled",         false,   "boolean"],
	["FramesNavFramePos",""],
	["FramesMainFrameName",   "main"],
	["WindowPadding",      15,	"number"],
	["HighestMenuNumber",  100,	"number"],
	["HoverTimeTop",       0,       "number"],
	["HoverTimeTree",      0,       "number"]
];

HM_MenuIDPrefix = "HM_Menu";
HM_ItemIDPrefix = "HM_Item";
HM_ArrayIDPrefix = "HM_Array";

Function.prototype.isFunction = true;
Function.prototype.isString = false;
String.prototype.isFunction = false;
String.prototype.isString = true;
String.prototype.isBoolean = false;
String.prototype.isNumber = false;
Number.prototype.isString = false;
Number.prototype.isFunction = false;
Number.prototype.isBoolean = false;
Number.prototype.isNumber = true;
Boolean.prototype.isString = false;
Boolean.prototype.isFunction = false;
Boolean.prototype.isBoolean = true;
Boolean.prototype.isNumber = false;
Array.prototype.itemValidation = false;
Array.prototype.isArray = true;

function HM_f_AssignParameters(paramarray){
	var ParamName = paramarray[0];
	var DefaultValue = paramarray[1];
	var FullParamName = "HM_" + ParamName;

	if (typeof eval("window.HM_PG_" + ParamName) == "undefined") {
		if (typeof eval("window.HM_GL_" + ParamName) == "undefined") {
			eval(FullParamName + "= DefaultValue");
		}
		else {
			eval(FullParamName + "= HM_GL_" + ParamName);
		}
	}
	else {
		eval(FullParamName + "= HM_PG_" + ParamName);
	}

	paramarray[0] = FullParamName;
	paramarray[1] = eval(FullParamName);
}

function HM_f_EvalParameters(valuenew,valueold,valuetype){
	var TestString, ParPosition;

	if(typeof valuenew == "undefined" || valuenew == null || (valuenew.isString && valuenew.length == 0)){
		return valueold;
	}

	if(valuetype != "delayed"){
		while(valuenew.isString) {
			ParPosition = valuenew.indexOf("(");
			if(ParPosition !=-1) {
				TestString = "window." + valuenew.substr(0,ParPosition);
				if (typeof eval(TestString) != "undefined" && eval(TestString).isFunction) {
					valuenew = eval(valuenew);
				}
			}
			else break;
		}
	}

	while(valuenew.isFunction) {valuenew = valuenew()}

	switch(valuetype){	
		case "number":
			while (valuenew.isString) {valuenew = eval(valuenew)}
			break;
		case "boolean":
			while (!valuenew.isBoolean) {
				valuenew = (valuenew.isNumber) ? valuenew ? true : false : eval(valuenew);
			}
			break;
		case "image":
			if (HM_ImageDir) valuenew = HM_ImageDir + valuenew;
			break;
	}

	return valuenew;
}

for (i=0;i<HM_a_Parameters.length;i++) {
	HM_f_AssignParameters(HM_a_Parameters[i]);
// 5.1
//	eval(HM_a_Parameters[i][0] + "= HM_f_EvalParameters("+ HM_a_Parameters[i][0] +",null,HM_a_Parameters[i][2])");
	window[HM_a_Parameters[i][0]] = HM_f_EvalParameters(window[HM_a_Parameters[i][0]],null,HM_a_Parameters[i][2]);
}

HM_ChildPerCentOver = (isNaN(parseFloat(HM_ChildPerCentOver))) ? null : parseFloat(HM_ChildPerCentOver)/100;

HM_ChildMilliSecondsVisible = HM_ChildSecondsVisible * 1000;

function HM_f_ValidateArray(arrayname){
	var MenuArrayIsValid = false;
	var MenuArrayIsObject = (typeof window[arrayname] == "object");
	if(MenuArrayIsObject) { 
		var TheMenuArray = window[arrayname];
		if(TheMenuArray.isArray && TheMenuArray.length > 1) {
			MenuArrayIsValid = true;
			if(!TheMenuArray.itemValidation) {
				while((typeof TheMenuArray[TheMenuArray.length-1] != "object") || (!TheMenuArray[TheMenuArray.length-1].isArray)) {
					TheMenuArray.length--;
				}
				TheMenuArray.itemValidation = true;
			}
		}
	}
	return MenuArrayIsValid;
}

// 5.1
// if(!window.HM_a_TreesToBuild) {
if(typeof(HM_a_TreesToBuild)=="undefined") {
	HM_a_TreesToBuild = [];
	for(i=1; i<=HM_HighestMenuNumber; i++){
		if(HM_f_ValidateArray(HM_ArrayIDPrefix + i)) HM_a_TreesToBuild[HM_a_TreesToBuild.length] = i;
	}
}

HM_AreLoaded = false;
HM_MenusTarget = window;
HM_a_AccessErrors = ["permission","access"];
HM_Resized=false;
HM_IsReloading=true;
HM_BeingCreated=false;

function HM_f_InitVars(){
	if(HM_Resized) return;
	if(typeof window != "undefined" && window.HM_AreCreated) {
		for(var i=0; i<HM_TotalTrees; i++) {
			var TopMenu = HM_a_TopMenus[i];
			clearTimeout(TopMenu.hideTimer);
			TopMenu.hideTimer = null;
	        }
	        clearTimeout(HM_HideAllTimer);
	}
	HM_CurrentArray = null;
	HM_CurrentTree  = null;
	HM_CurrentMenu  = null;
	HM_CurrentItem  = null;
	HM_a_TopMenus = [];
	HM_AreCreated = false;
	HM_UserOverMenu = false;
	HM_HideAllTimer = null;
	HM_TotalTrees = 0; 
	HM_ZIndex = 5000;
	HM_ScrollTimer = null;
}

HM_f_InitVars();

if(HM_FramesEnabled){
	if((parent == self) || (!HM_FramesNavFramePos)){
		HM_FramesEnabled = false;
	}
}

Layer.prototype.showIt = HM_f_ShowIt;
Layer.prototype.keepInWindow = HM_f_KeepInWindow;
Layer.prototype.hideTree = HM_f_HideTree;
Layer.prototype.hideParents = HM_f_HideParents;
Layer.prototype.hideChildren = HM_f_HideChildren;
Layer.prototype.hideTop = HM_f_HideTop;
Layer.prototype.hideSelf = HM_f_HideSelf;
Layer.prototype.hasChildVisible = false;
Layer.prototype.isOn = false;
Layer.prototype.hideTimer = null;
Layer.prototype.currentItem = null;
Layer.prototype.itemSetup = HM_f_ItemSetup;
Layer.prototype.itemCount = 0;
Layer.prototype.child = null;
Layer.prototype.isWritten = false;
Layer.prototype.scrollbarsCreated = false;
Layer.prototype.enableScrolling = HM_f_EnableScrolling;
Layer.prototype.createScrollbars = HM_f_CreateScrollbars;
Layer.prototype.checkScroll = HM_f_CheckScroll;
Layer.prototype.startScroll = HM_f_StartScroll;
Layer.prototype.topCount = 0;

function HM_f_FrameLoad(e){
	HM_BeingCreated = true;
	HM_f_InitVars();
	HM_AreCreated = HM_f_StartIt(e);
	HM_IsReloading = false;
	HM_BeingCreated = false;
// 5.1
	HM_AreLoaded = true;
	if(e) HM_f_OtherOnLoad();
	return HM_AreCreated; 
}

function HM_f_CheckFrameLoad(e){
// 5.1
//	if (e.target.name == HM_FramesMainFrameName){
	if (e.target == HM_MenusTarget){
		HM_f_FrameLoad();
		routeEvent(e);
	}
}

function HM_f_CheckFrameUnload(e){
	if(typeof(window) == "undefined") return;
	if(HM_Resized) return;
// 5.1
//	if(e.target.name == HM_FramesMainFrameName) {
	if(e.target == HM_MenusTarget) {
		HM_IsReloading = true;
		HM_f_InitVars();
		routeEvent(e);
	}
// 5.1
	else if (e.target==window) {
		HM_IsReloading = true;
		HM_LoadElement.releaseEvents(Event.LOAD);
		HM_LoadElement.releaseEvents(Event.UNLOAD);
		routeEvent(e);
	}
}

function HM_f_DocumentMouseDown(e) {
	HM_f_PageClick();
	HM_MenusTarget.document.routeEvent(e);
}

function HM_f_StartIt(e) {
// 5.1
//	if(HM_AreCreated) return false;
//	HM_AreLoaded = true;

// 5.1
	HM_LoadElement = (HM_FramesEnabled) ? top : window;

	if(HM_FramesEnabled){
		var TargetFrame = parent.frames[HM_FramesMainFrameName];
		if(typeof TargetFrame == "undefined"){
			HM_FramesEnabled = false;
			HM_LoadElement.releaseEvents(Event.LOAD);
			HM_LoadElement.releaseEvents(Event.UNLOAD);
		}
		else {
			HM_MenusTarget = TargetFrame;
			if(e){
				HM_LoadElement.captureEvents(Event.LOAD);
				HM_LoadElement.onload = HM_f_CheckFrameLoad;
				HM_LoadElement.captureEvents(Event.UNLOAD);
				HM_LoadElement.onunload = HM_f_CheckFrameUnload;
				if (HM_f_IsInitialized()) {
					HM_MenusTarget.location.replace(HM_MenusTarget.location.href);
					return false;
				}
			}
		}
	}

	HM_OrigWidth  = HM_MenusTarget.innerWidth;
	HM_OrigHeight = HM_MenusTarget.innerHeight;

	HM_MenusTarget.onresize = HM_f_ResizeHandler;

	if (HM_ClickKill) {
		HM_MenusTarget.document.captureEvents(Event.MOUSEDOWN);
	    	HM_MenusTarget.document.onmousedown = HM_f_DocumentMouseDown;
	}
	else {
		HM_TopMilliSecondsVisible = HM_TopSecondsVisible * 1000;
	}

// 5.1
	HM_MenusTarget.HM_Initialized=true;

	HM_f_MakeTrees();
	return true;
}

// 5.1
function HM_f_IsInitialized() {
	if ((HM_MenusTarget) &&
	    (typeof(HM_MenusTarget.HM_Initialized)=="boolean") &&
	    (HM_MenusTarget.HM_Initialized)) return true;
	else return false;
}

function HM_f_GetMenu(menuid) {
	var TheMenu = null;
	if (HM_MenusTarget)  {
		TheMenu = HM_MenusTarget[menuid];
	}
	return TheMenu;
}

function HM_f_MakeTrees(){
	var TreeParams = null;
	var TreeHasChildren = false;
	var ItemArray = null;

	for(var t=0; t<HM_a_TreesToBuild.length; t++) {
		if(!HM_f_ValidateArray(HM_ArrayIDPrefix + HM_a_TreesToBuild[t])) continue;
		HM_CurrentArray = window[HM_ArrayIDPrefix + HM_a_TreesToBuild[t]];

		TreeParams = HM_CurrentArray[0];
		TreeHasChildren = false;

		for(var i=1; i<HM_CurrentArray.length; i++) {
			ItemArray = HM_CurrentArray[i];
			if(ItemArray[ItemArray.length-1]) {TreeHasChildren = true; break}
		}

		HM_CurrentTree = {
			MenuWidth        : MenuWidth = HM_f_EvalParameters(TreeParams[0],HM_MenuWidth,"number"),
			MenuLeft         : MenuLeft = HM_f_EvalParameters(TreeParams[1],null,"delayed"),
			MenuTop          : MenuTop = HM_f_EvalParameters(TreeParams[2],null,"delayed"),
			ItemWidth        : ItemWidth = MenuWidth - (HM_BorderWidth*2),
			ItemTextWidth    : TreeHasChildren ? (ItemWidth - (HM_ImageSize + HM_ImageHorizSpace + HM_ItemPadding)) : ItemWidth,
			FontColor        : FontColor = HM_f_EvalParameters(TreeParams[3],HM_FontColor),
			FontColorOver    : FontColorOver = HM_f_EvalParameters(TreeParams[4],HM_FontColorOver),
			BGColor          : HM_f_EvalParameters(TreeParams[5],HM_BGColor),
			BGColorOver      : HM_f_EvalParameters(TreeParams[6],HM_BGColorOver),
			BorderColor      : HM_f_EvalParameters(TreeParams[7],HM_BorderColor),
			TopIsPermanent   : ((MenuLeft == null) || (MenuTop == null)) ? false : HM_f_EvalParameters(TreeParams[9],false,"boolean"),
			TopIsHorizontal  : TopIsHorizontal = HM_f_EvalParameters(TreeParams[10],false,"boolean"),
			TreeIsHorizontal : TreeHasChildren ? HM_f_EvalParameters(TreeParams[11],false,"boolean") : false,
			PositionUnder    : (!TopIsHorizontal || !TreeHasChildren) ? false : HM_f_EvalParameters(TreeParams[12],false,"boolean"),
			TopImageShow     : TreeHasChildren ? HM_f_EvalParameters(TreeParams[13],true,"boolean")  : false,
			TreeImageShow    : TreeHasChildren ? HM_f_EvalParameters(TreeParams[14],true,"boolean")  : false,
			UponDisplay      : HM_f_EvalParameters(TreeParams[15],HM_UponDisplay,"delayed"),
			UponHide         : HM_f_EvalParameters(TreeParams[16],HM_UponHide,"delayed"),
			RightToLeft      : HM_f_EvalParameters(TreeParams[17],HM_RightToLeft,"boolean"),
			NSFontOver	 : HM_NSFontOver ? (FontColor != FontColorOver) : false,
			ClickStart	 : HM_f_EvalParameters(TreeParams[18],HM_ClickStart,"boolean"),
			TopIsVariableWidth  : HM_f_EvalParameters(TreeParams[19],false,"boolean"),
			TreeIsVariableWidth  : HM_f_EvalParameters(TreeParams[20],false,"boolean")
		};

		HM_CurrentMenu = null;
		HM_f_MakeMenu(HM_a_TreesToBuild[t]);
		HM_a_TopMenus[HM_TotalTrees] = HM_CurrentTree.treeParent;
		HM_TotalTrees++;
		if(HM_CurrentTree.TopIsPermanent){
			with(HM_CurrentTree.treeParent) {
				moveTo(eval(HM_CurrentTree.MenuLeft),eval(HM_CurrentTree.MenuTop));
				zIndex = HM_ZIndex;
				visibility = "show";
			}
		}
	}

	if(HM_StatusDisplayBuild) window.status = HM_TotalTrees + " Hierarchical Menu Trees Created";
}

function HM_f_GetItemHtmlStr(arraystring){
	var TempString = arraystring;
	if (HM_FontBold) TempString = TempString.bold();
	if (HM_FontItalic) TempString = TempString.italics();
	TempString = "<FONT FACE='" + HM_FontFamily + "' POINT-SIZE=" + HM_FontSize + ">" + TempString + "</FONT>";
	var TempStringOver = TempString.fontcolor(HM_CurrentTree.FontColorOver);
	TempString = TempString.fontcolor(HM_CurrentTree.FontColor);
	return [TempString,TempStringOver];
}

function HM_f_MakeMenu(menucount) {
	if(!HM_f_ValidateArray(HM_ArrayIDPrefix + menucount)) return false;
	HM_CurrentArray = window[HM_ArrayIDPrefix + menucount];
	var NewMenu = HM_MenusTarget[HM_MenuIDPrefix + menucount];
	if(!NewMenu) {
		NewMenu = HM_MenusTarget[HM_MenuIDPrefix + menucount] = new Layer(HM_CurrentTree.MenuWidth,HM_MenusTarget);
		if(HM_ScrollEnabled) {
			NewMenu.scrollParent = new Layer(HM_CurrentTree.MenuWidth,NewMenu);
			NewMenu.scrollParent.visibility = "inherit";
		}
		else {
			NewMenu.scrollParent = NewMenu;
		}

		if(HM_CurrentMenu) {
			NewMenu.parentMenu = HM_CurrentMenu;
			NewMenu.parentItem = HM_CurrentItem;
			NewMenu.parentItem.child = NewMenu;
			NewMenu.hasParent = true;
			NewMenu.isHorizontal = HM_CurrentTree.TreeIsHorizontal;
			NewMenu.showImage = HM_CurrentTree.TreeImageShow;
		}
		else {
			NewMenu.isHorizontal = HM_CurrentTree.TopIsHorizontal;
			NewMenu.showImage = HM_CurrentTree.TopImageShow;
		}
	
		HM_CurrentMenu = NewMenu;
		HM_CurrentMenu.count = menucount;
		HM_CurrentMenu.tree  = HM_CurrentTree;
		HM_CurrentMenu.array = HM_CurrentArray;
		HM_CurrentMenu.maxItems = HM_CurrentArray.length - 1;
		HM_CurrentMenu.bgColor = HM_CurrentTree.BorderColor;
		HM_CurrentMenu.IsVariableWidth = ((HM_CurrentMenu.hasParent && HM_CurrentTree.TreeIsVariableWidth) || (!HM_CurrentMenu.hasParent && HM_CurrentTree.TopIsVariableWidth));
		HM_CurrentMenu.onmouseover = HM_f_MenuOver;
		HM_CurrentMenu.onmouseout = HM_f_MenuOut;
		HM_CurrentMenu.layerid = HM_MenuIDPrefix + menucount;
		HM_CurrentMenu.moveTo(0,0);
	}

	if(!HM_CurrentTree.treeParent) HM_CurrentTree.treeParent = HM_CurrentTree.startChild = HM_CurrentMenu;

	while (HM_CurrentMenu.itemCount < HM_CurrentMenu.maxItems) {
		HM_CurrentMenu.itemCount++;
		HM_CurrentItem = HM_MenusTarget[HM_ItemIDPrefix + menucount + "_" + HM_CurrentMenu.itemCount];
		if(!HM_CurrentItem) {
			if(HM_StatusDisplayBuild) window.status = "Creating Hierarchical Menus: " + menucount + " / " + HM_CurrentMenu.itemCount;
			HM_CurrentItem = HM_MenusTarget[HM_ItemIDPrefix + menucount + "_" + HM_CurrentMenu.itemCount] = new Layer(HM_CurrentTree.ItemWidth - (HM_ItemPadding*2),HM_CurrentMenu.scrollParent);
			HM_CurrentItem.itemSetup(menucount + "_" + HM_CurrentMenu.itemCount);
		}
		if(HM_CurrentItem.hasMore && (!HM_CreateTopOnly || HM_AreCreated && HM_CreateTopOnly)) {
		       	MenuCreated = HM_f_MakeMenu(menucount + "_" + HM_CurrentMenu.itemCount);
	           	if(MenuCreated) {
				HM_CurrentMenu =  HM_CurrentMenu.parentMenu;
				HM_CurrentArray = HM_CurrentMenu.array;
			}
		}
	}
	HM_CurrentMenu.itemCount = 0;
	if (HM_CurrentMenu.isHorizontal) {
		HM_CurrentMenu.clip.right = HM_CurrentMenu.scrollParent.clip.right = HM_CurrentMenu.lastItem.left + HM_CurrentMenu.lastItem.clip.right + HM_BorderWidth;
	}
	else {
		HM_CurrentMenu.clip.right = HM_CurrentMenu.scrollParent.clip.right = HM_CurrentMenu.lastItem.clip.width + (HM_BorderWidth*2);
	}
	HM_CurrentMenu.clip.bottom = HM_CurrentMenu.scrollParent.clip.bottom = HM_CurrentMenu.lastItem.top + HM_CurrentMenu.lastItem.clip.bottom + HM_BorderWidth;

	return HM_CurrentMenu;
}

function HM_f_ItemSetup(itemidsuffix) {
	this.menu = HM_CurrentMenu;
	this.tree = HM_CurrentTree;
	this.index = HM_CurrentMenu.itemCount - 1;
	this.array = HM_CurrentArray[HM_CurrentMenu.itemCount];
	this.dispText = this.array[0];
	this.linkText = this.array[1];
	this.permHilite  = HM_f_EvalParameters(this.array[3],false,"boolean");
	this.hasRollover = (!this.permHilite && HM_f_EvalParameters(this.array[2],true,"boolean"));
	this.hasMore	 = HM_f_EvalParameters(this.array[4],false,"boolean") && HM_f_ValidateArray(HM_ArrayIDPrefix + itemidsuffix);
	var HtmlStrings = HM_f_GetItemHtmlStr(this.dispText);
	this.htmStr = HtmlStrings[0];
	this.htmStrOver = HtmlStrings[1];
	this.visibility = "inherit";
	this.onmouseover = HM_f_ItemOver;
	this.onmouseout  = HM_f_ItemOut;
	this.menu.lastItem = this;
	this.showChild = HM_f_ShowChild;
	this.hoverChild = HM_f_HoverChild;
	this.hoverTime = (this.menu == this.tree.startChild) ? HM_HoverTimeTop : HM_HoverTimeTree;
	this.childTimer = null;
	eval(this.id + " = this");
	this.layerid = HM_ItemIDPrefix + itemidsuffix;

	this.ClickStart = this.hasMore && this.tree.ClickStart && (this.tree.TopIsPermanent && (this.tree.treeParent==this.menu));
	if(this.ClickStart) {
		this.captureEvents(Event.MOUSEUP);
		this.onmouseup = this.hoverChild;
		this.linkText = "";
	}
	else {
		if (this.linkText) {
			this.captureEvents(Event.MOUSEUP);
			this.onmouseup = HM_f_LinkIt;
		}
	}

	this.txtLyrOff = new Layer(HM_CurrentTree.ItemTextWidth - (HM_ItemPadding*2),this);
	with(this.txtLyrOff) {
		document.write(this.permHilite ? this.htmStrOver : this.htmStr);
		document.close();
		if (HM_CurrentTree.RightToLeft && this.menu.showImage && (!this.menu.isHorizontal || (this.menu.isHorizontal && (!this.menu.IsVariableWidth || (this.menu.IsVariableWidth && this.hasMore))) )) left = HM_ItemPadding + HM_ImageSize + HM_ImageHorizSpace;
		visibility = "inherit";
	}

	if(this.menu.IsVariableWidth){
		this.ItemTextWidth = this.txtLyrOff.document.width;
		this.ItemWidth = this.ItemTextWidth + (HM_ItemPadding*2);
		if(HM_CurrentMenu.showImage) {
			if(!this.menu.isHorizontal || this.hasMore) {
				this.ItemWidth += (HM_ItemPadding + HM_ImageSize + HM_ImageHorizSpace);
			}
		}
	}
	else {
		this.ItemWidth = this.tree.ItemWidth;
		this.ItemTextWidth = this.tree.ItemTextWidth;
	}
	if (this.menu.isHorizontal) {
		if (this.index) this.left = this.siblingBelow.left + this.siblingBelow.clip.width + HM_SeparatorSize;
		else this.left = (HM_BorderWidth + HM_ItemPadding);
		this.top = (HM_BorderWidth + HM_ItemPadding);
	}
	else {
		this.left = (HM_BorderWidth + HM_ItemPadding);
		if (this.index) this.top = this.siblingBelow.top + this.siblingBelow.clip.height + HM_SeparatorSize;
		else this.top = (HM_BorderWidth + HM_ItemPadding);
	}
	this.clip.top = this.clip.left = -HM_ItemPadding;
	this.clip.right = this.ItemWidth - HM_ItemPadding;
	this.bgColor = this.permHilite ? this.tree.BGColorOver : this.tree.BGColor;

	if(this.tree.NSFontOver) {
		if(!this.permHilite){
			this.txtLyrOn = new Layer(this.ItemTextWidth,this);
			with(this.txtLyrOn) {
				if (HM_CurrentTree.RightToLeft && this.menu.showImage && (!this.menu.isHorizontal || (this.menu.isHorizontal && (!this.menu.IsVariableWidth || (this.menu.IsVariableWidth && this.hasMore))) ))  left = HM_ItemPadding + HM_ImageSize + HM_ImageHorizSpace;
				visibility = "hide";
			}
		}
	}

	this.fullClip = this.txtLyrOff.document.height + (HM_ItemPadding * 2);
	if(this.menu.isHorizontal) {
		if(this.index) {
			var SiblingHeight = this.siblingBelow.clip.height;
			this.fullClip = Math.max(SiblingHeight,this.fullClip);
			if(this.fullClip > SiblingHeight) {
				var SiblingPrevious = this.siblingBelow;
				while(SiblingPrevious != null) {
					SiblingPrevious.clip.height = this.fullClip;
					SiblingPrevious = SiblingPrevious.siblingBelow;
				}
			}
		}
	}
	this.clip.height = this.fullClip;

	if(!this.menu.isHorizontal && this.menu.IsVariableWidth) {
		this.fullWidth = this.clip.width;
		if(this.index) {
			var SiblingWidth = this.siblingBelow.clip.width;
			this.fullWidth = Math.max(SiblingWidth,this.fullWidth);
			SiblingPrevious = this.siblingBelow;
			while(SiblingPrevious != null) {
				SiblingPrevious.clip.width = this.fullWidth;
				SiblingPrevious.dummyLyr.clip.width = this.fullWidth;
				if(SiblingPrevious.hasMore) {
					SiblingPrevious.DistanceToRightEdge = SiblingPrevious.clip.right + SiblingPrevious.WhatsOnRight;
					SiblingPrevious.DistanceToLeftEdge = HM_ItemPadding + SiblingPrevious.WhatsOnLeft;
					SiblingPrevious.CompleteWidth = SiblingPrevious.ItemWidth + SiblingPrevious.WhatsOnLeft + SiblingPrevious.WhatsOnRight;
					SiblingPrevious.ChildOverlap = (parseInt((HM_ChildPerCentOver != null) ? (HM_ChildPerCentOver  * SiblingPrevious.CompleteWidth) : HM_ChildOverlap));
				}
				if(SiblingPrevious.imgLyr && !HM_CurrentTree.RightToLeft) {
					SiblingPrevious.imgLyr.left = this.fullWidth - (HM_ItemPadding * 2) - HM_ImageSize - HM_ImageHorizSpace;
				}
				SiblingPrevious = SiblingPrevious.siblingBelow;
			}
		}
		this.clip.width = this.fullWidth;
	}

	this.dummyLyr = new Layer(100,this);
	with(this.dummyLyr) {
		left = top = -HM_ItemPadding;
		clip.width = this.clip.width;
		clip.height = this.clip.height;
		visibility = "inherit";
	}

	this.hasImageRollover = false;
	if(this.hasMore && HM_CurrentMenu.showImage) {
		this.imageSrc = this.tree.RightToLeft ? HM_ImageSrcLeft : HM_ImageSrc;
		if(!this.tree.RightToLeft) {
			this.hasImageRollover = (HM_ImageSrcOver&&(HM_ImageSrcOver!=HM_ImageSrc));
		}
		else {
			this.hasImageRollover = (HM_ImageSrcLeftOver&&(HM_ImageSrcLeftOver!=HM_ImageSrcLeft));
		}
		if(this.hasImageRollover) {
			this.imageSrcOver = this.tree.RightToLeft ? HM_ImageSrcLeftOver : HM_ImageSrcOver;
			if(!this.imageSrcOver) this.imageSrcOver = this.imageSrc;
			if(this.permHilite) this.imageSrc = this.imageSrcOver;
		}
		this.imgLyr = new Layer(HM_ImageSize,this);

		with(this.imgLyr) {
			document.write("<IMG SRC='" + this.imageSrc + "' WIDTH=" + HM_ImageSize + " VSPACE=0 HSPACE=0 BORDER=0>");
			document.close();
			moveBelow(this.txtLyrOff);
			left = (HM_CurrentTree.RightToLeft) ? HM_ImageHorizSpace : this.clip.width - (HM_ItemPadding * 2) - HM_ImageSize - HM_ImageHorizSpace;
			top = HM_ImageVertSpace;
			visibility = "inherit";
		}
		this.imageElement = this.imgLyr.document.images[0];
	}

	if(this.hasMore) {
		this.WhatsOnRight = (!this.menu.isHorizontal || (this.menu.isHorizontal && this.isLastItem)) ?  HM_BorderWidth : HM_SeparatorSize;
		this.DistanceToRightEdge = this.clip.right + this.WhatsOnRight;
		this.WhatsOnLeft = (!this.menu.isHorizontal || (this.menu.isHorizontal && this.index==0)) ? HM_BorderWidth : HM_SeparatorSize;
		this.DistanceToLeftEdge = HM_ItemPadding + this.WhatsOnLeft;
		this.CompleteWidth = this.ItemWidth + this.WhatsOnLeft + this.WhatsOnRight;
		this.ChildOverlap = (parseInt((HM_ChildPerCentOver != null) ? (HM_ChildPerCentOver  * this.CompleteWidth) : HM_ChildOverlap));
	}
}

function HM_f_PopUp(menuname,e){
	if(!HM_AreLoaded) return;
	if(HM_IsReloading) return;
	if(!HM_BeingCreated && !HM_AreCreated){
		if(!HM_f_FrameLoad()) return;
	}
	menuname = menuname.replace("elMenu",HM_MenuIDPrefix);
	var TempMenu = HM_MenusTarget[menuname];
	if(!TempMenu)return;
	if (TempMenu.tree.ClickStart) {
		var ClickElement = e.target;
		var OnClickFunction = "return HM_f_PopMenu(event,'" + menuname + "');";
		ClickElement.onclick = new Function("event",OnClickFunction);
	}
	else HM_f_PopMenu(e,menuname);
}

function HM_f_PopMenu(e,menuname){
	if (!HM_AreLoaded || !HM_AreCreated) return true;
	if (HM_IsReloading) return true;
	var TempMenu = HM_MenusTarget[menuname];
	if(!TempMenu)return true;
	HM_CurrentMenu=TempMenu;
	if (HM_CurrentMenu.tree.ClickStart && e.type != "click") return true;
	HM_f_HideAll();
	HM_CurrentMenu.hasParent = false;
	HM_CurrentMenu.tree.startChild = HM_CurrentMenu;

	if(!HM_FramesNavFramePos){
		var mouse_x_position = e.pageX;
		var mouse_y_position = e.pageY;
	}
	else {
		switch (HM_FramesNavFramePos) {
			case "left":
				var mouse_x_position = HM_MenusTarget.pageXOffset;
				var mouse_y_position = (e.pageY-window.pageYOffset)+HM_MenusTarget.pageYOffset;
				break;
			case "top":
				var mouse_x_position = (e.pageX-window.pageXOffset)+HM_MenusTarget.pageXOffset;
				var mouse_y_position = HM_MenusTarget.pageYOffset;
				break;
			case "bottom":
				var mouse_x_position = (e.pageX-window.pageXOffset)+HM_MenusTarget.pageXOffset;
				var mouse_y_position = HM_MenusTarget.pageYOffset+HM_MenusTarget.innerHeight;
				break;
			case "right":
				var mouse_x_position = (HM_MenusTarget.pageXOffset+HM_MenusTarget.innerWidth);
				var mouse_y_position = (e.pageY-window.pageYOffset)+HM_MenusTarget.pageYOffset;
				break;
			case "left":
			default:
				var mouse_x_position = HM_MenusTarget.pageXOffset;
				var mouse_y_position = (e.pageY-window.pageYOffset)+HM_MenusTarget.pageYOffset;
				break;
		}
	}

	HM_CurrentMenu.xPos = (HM_CurrentMenu.tree.MenuLeft!=null) ? eval(HM_CurrentMenu.tree.MenuLeft) : mouse_x_position;
	HM_CurrentMenu.yPos = (HM_CurrentMenu.tree.MenuTop!=null)  ? eval(HM_CurrentMenu.tree.MenuTop)  : mouse_y_position;

	HM_CurrentMenu.keepInWindow();
	HM_CurrentMenu.moveTo(HM_CurrentMenu.xPos,HM_CurrentMenu.yPos);
	HM_CurrentMenu.isOn = true;
	HM_CurrentMenu.showIt(true);
	return false;
}

function HM_f_MenuOver() {
	if(HM_IsReloading) return;
	if(!this.tree.startChild) this.tree.startChild = this;
	if(this.tree.startChild == this) HM_f_HideAll(this);
	this.isOn = true;
	HM_UserOverMenu = true;
	HM_CurrentMenu = this;
	if (this.hideTimer) clearTimeout(this.hideTimer);
}

function HM_f_MenuOut() {
	if(HM_IsReloading) return;
	this.isOn = false;
	HM_UserOverMenu = false;
	if(HM_StatusDisplayLink) window.status = "";

	var Items = this.scrollParent.layers;
	var ItemCount = Items.length;
	var TempItem;
	for(var i=0;i<ItemCount;i++){
		TempItem = Items[i];
		clearTimeout(TempItem.childTimer);
		TempItem.childTimer = null;
	}

	if(!HM_ClickKill) {
		clearTimeout(HM_HideAllTimer);
		HM_HideAllTimer = null;
		var TimeoutCommand = "var HM_MenuOutMenuToHide = HM_f_GetMenu('" + this.layerid + "'); if (HM_MenuOutMenuToHide && HM_MenuOutMenuToHide.hideTree) HM_MenuOutMenuToHide.hideTree()";
		HM_HideAllTimer = setTimeout(TimeoutCommand,HM_ChildMilliSecondsVisible);
	}
}

function HM_f_ShowChild(){
	if(!this.child) {
		HM_CurrentTree = this.tree;
		HM_CurrentMenu = this.menu;
		HM_CurrentItem = this;
		this.child = HM_f_MakeMenu(this.menu.count + "_" + (this.index+1));
		this.tree.treeParent = this.menu;
		this.tree.startChild = this.menu;
		HM_CurrentMenu = this.menu;	
	}

	if(this.menu.hidden) return;

	if (this.tree.PositionUnder && (this.menu == this.tree.treeParent)) {
		this.child.xPos = this.pageX + this.clip.left - HM_BorderWidth;
		this.child.yPos = this.menu.top + this.menu.clip.height - HM_BorderWidth;
	}
	else {
		this.oL = this.pageX;
		this.child.offsetWidth = this.child.clip.width;
		this.oT = this.pageY + this.clip.top - HM_BorderWidth;
		if(this.tree.RightToLeft) {
			this.child.xPos = ((this.oL - this.DistanceToLeftEdge) + this.ChildOverlap) - this.child.offsetWidth;
		}
		else {		
			this.child.xPos = (this.oL + this.DistanceToRightEdge) - this.ChildOverlap;
		}
		this.child.yPos = this.oT + HM_ChildOffset + HM_BorderWidth;
	}
	if(!this.tree.PositionUnder || this.menu!=this.tree.treeParent) this.child.keepInWindow();
	this.child.moveTo(this.child.xPos,this.child.yPos);
	this.menu.hasChildVisible = true;
	this.menu.visibleChild = this.child;
	this.child.showIt(true);
}

function HM_f_ItemOver(){
	if(HM_IsReloading) return;
	var ItemMenu = this.menu;
	var FontOver = this.tree.NSFontOver;

	if (HM_KeepHilite) {
		if (ItemMenu.currentItem && ItemMenu.currentItem != this && ItemMenu.currentItem.hasRollover) {
			with(this.menu.currentItem){
				bgColor = this.tree.BGColor;
				if(FontOver) {
					txtLyrOff.visibility = "inherit";
					txtLyrOn.visibility = "hide";
				}
			}
			if(this.menu.currentItem.hasImageRollover) this.menu.currentItem.imageElement.src = this.menu.currentItem.imageSrc;
		}
		if(ItemMenu != this.tree.startChild){
			var ParentMenu = ItemMenu.parentMenu;
			if (ParentMenu.currentItem && ParentMenu.currentItem.hasRollover) {
				with(ParentMenu.currentItem){
					bgColor = this.tree.BGColor;
					if(FontOver) {
						txtLyrOff.visibility = "inherit";
						txtLyrOn.visibility = "hide";
					}
				}
				if(ParentMenu.currentItem.hasImageRollover) ParentMenu.currentItem.imageElement.src = ParentMenu.currentItem.imageSrc;
			}
			var ParentItem = ItemMenu.parentItem;
			if(ParentItem.hasRollover) {
				with(ParentItem){
					bgColor = this.tree.BGColorOver;
					if(FontOver) {
						txtLyrOn.visibility = "inherit";
						txtLyrOff.visibility = "hide";
					}
				}
				if(ParentItem.hasImageRollover) ParentItem.imageElement.src = ParentItem.imageSrcOver;
			}
			ParentMenu.currentItem = ParentItem;
		}
	}
	if(this.hasRollover) {
		this.bgColor = this.tree.BGColorOver;
		if(this.tree.NSFontOver) {
			if(!this.txtLyrOn.isWritten){
				this.txtLyrOn.document.write(this.htmStrOver);
				this.txtLyrOn.document.close();
				this.txtLyrOn.isWritten = true;
			}
			this.txtLyrOff.visibility = "hide";
			this.txtLyrOn.visibility = "inherit";
		}
		if(this.hasImageRollover) this.imageElement.src = this.imageSrcOver;
	}

	if(HM_StatusDisplayLink) window.status = this.linkText;
	this.menu.currentItem = this;
		
	var Items = ItemMenu.scrollParent.layers;
	var ItemCount = Items.length;
	var TempItem;
	for(var i=0;i<ItemCount;i++){
		TempItem = Items[i];
		clearTimeout(TempItem.childTimer);
		TempItem.childTimer = null;
	}
	
	var TimeoutCommand = "if (HM_MenusTarget && HM_MenusTarget['"+this.layerid+"'] && ";
	TimeoutCommand += "HM_MenusTarget['"+this.layerid+"'].hoverChild) ";
	TimeoutCommand += "HM_MenusTarget['"+this.layerid+"'].hoverChild(true)";
	if(this.hoverTime>0) this.childTimer = setTimeout(TimeoutCommand,this.hoverTime);
	else this.hoverChild(true);
}

function HM_f_HoverChild(onover){
	if(HM_IsReloading) return;
	onover = onover.isBoolean;
	if (this.menu.hasChildVisible) {
		if(this.menu.visibleChild == this.child && this.menu.visibleChild.hasChildVisible) this.menu.visibleChild.hideChildren(this);
		else this.menu.hideChildren(this);
	}
	if ((this.ClickStart && !onover) || (this.hasMore && !this.ClickStart)) this.showChild();
}

function HM_f_ItemOut() {
	if(HM_IsReloading) return;
	if(this.hasRollover){
		with(this){
			bgColor = this.tree.BGColor;
			if(this.tree.NSFontOver) {
				txtLyrOff.visibility = "inherit";
				txtLyrOn.visibility = "hide";
			}
			if(this.hasImageRollover) this.imageElement.src = this.imageSrc;
		}
	}
	if(!HM_ClickKill && !HM_UserOverMenu) {
		clearTimeout(HM_HideAllTimer);
		HM_HideAllTimer = null;
		var TimeoutCommand = "var HM_ItemOutMenuToHide = HM_f_GetMenu('" + this.menu.layerid + "'); if (HM_ItemOutMenuToHide && HM_ItemOutMenuToHide.hideTree) HM_ItemOutMenuToHide.hideTree()";
		HM_HideAllTimer = setTimeout(TimeoutCommand,HM_ChildMilliSecondsVisible);
	}
}

function HM_f_ShowIt(on) {
	if (!(this.tree.TopIsPermanent && (this.tree.treeParent==this))) {
		if(!this.hasParent || (this.hasParent && this.tree.TopIsPermanent && (this.tree.treeParent==this.parentMenu))) {
			if (on == this.hidden)
				eval(on ? this.tree.UponDisplay : this.tree.UponHide);
		}
		if (on) this.zIndex = ++HM_ZIndex;
		this.visibility = on ? "show" : "hide";
	}
	if (HM_KeepHilite && this.currentItem && this.currentItem.hasRollover) {
		with(this.currentItem){
			bgColor = this.tree.BGColor;
			if(this.tree.NSFontOver) {
				txtLyrOff.visibility = "inherit";
				txtLyrOn.visibility = "hide";
			}
		}
		if(this.currentItem.hasImageRollover) this.currentItem.imageElement.src = this.currentItem.imageSrc;
	}
	this.currentItem = null;
}

function HM_f_KeepInWindow() {
	var ExtraSpace     = HM_WindowPadding;
	var WindowLeftEdge = HM_MenusTarget.pageXOffset;
	var WindowTopEdge  = HM_MenusTarget.pageYOffset;
	var WindowWidth    = HM_MenusTarget.innerWidth;
	var WindowHeight   = HM_MenusTarget.innerHeight;
	var WindowRightEdge  = (WindowLeftEdge + WindowWidth) - ExtraSpace;
	var WindowBottomEdge = (WindowTopEdge + WindowHeight) - ExtraSpace;

	var MenuLeftEdge = this.xPos;
	var MenuRightEdge = MenuLeftEdge + this.clip.width;

	if(this.yPos < WindowTopEdge) this.yPos = WindowTopEdge; 

	var MenuBottomEdge = this.yPos + this.clip.height;

	if (this.hasParent) {
		var ParentLeftEdge = this.parentItem.pageX;
		this.offsetWidth = this.clip.width;
	}
	if (MenuRightEdge > WindowRightEdge) {
		if (this.hasParent) {
			this.xPos = ((ParentLeftEdge - this.parentItem.DistanceToLeftEdge) + this.parentItem.ChildOverlap) - this.offsetWidth;
		}
		else {
			var dif = MenuRightEdge - WindowRightEdge;
			this.xPos -= dif;
		}
		this.xPos = Math.max(5,this.xPos);
	}

	if (MenuBottomEdge > WindowBottomEdge) {
		var dif = MenuBottomEdge - WindowBottomEdge;
		this.yPos -= dif;
	}

	if (MenuLeftEdge < WindowLeftEdge) {
		if (this.hasParent) {
			this.xPos = (ParentLeftEdge + this.parentItem.DistanceToRightEdge) - this.parentItem.ChildOverlap;
			MenuRightEdge = this.xPos + this.offsetWidth;
			if(MenuRightEdge > WindowRightEdge) this.xPos -= (MenuRightEdge - WindowRightEdge);
		}
		else {this.xPos = 5}
	}
	if(HM_ScrollEnabled && (this.yPos < WindowTopEdge)) this.enableScrolling(WindowTopEdge);
}

function HM_f_LinkIt() {
	if(HM_IsReloading) return;
	if (this.linkText.indexOf("javascript:")!=-1) eval(this.linkText);
	else {
		HM_f_HideAll();
		if(document.getElementById("MainIFrame")){
			document.getElementById("MainIFrame").src = this.linkText;
		}else{
			HM_MenusTarget.location.href = this.linkText;
		}
		//document.bottom.location.href = this.linkText;
	}
}

function HM_f_PopDown(menuname){
	if (!HM_AreLoaded || !HM_AreCreated) return;
	if(HM_IsReloading) return;
	menuname = menuname.replace("elMenu",HM_MenuIDPrefix);
	var MenuToHide = HM_MenusTarget[menuname];
	if(!MenuToHide)return;
	if(HM_UserOverMenu&&(HM_CurrentMenu==MenuToHide)) return;
	MenuToHide.isOn = false;
	if (!HM_ClickKill) MenuToHide.hideTop();
}

function HM_f_HideAll(callingmenu) {
	clearTimeout(HM_HideAllTimer);
	HM_HideAllTimer = null;
	for(var i=0; i<HM_TotalTrees; i++) {
		var TopMenu = HM_a_TopMenus[i].tree.startChild;
		if(TopMenu == callingmenu) continue;
		TopMenu.isOn = false;
		if (TopMenu.hasChildVisible) TopMenu.hideChildren();
		TopMenu.showIt(false);
	}    
}

function HM_f_HideTree() { 
	HM_HideAllTimer = null;
	if (HM_UserOverMenu) return;
	if (HM_IsReloading) return;
	if (this.hasChildVisible) this.hideChildren();
	this.hideParents();
}

function HM_f_HideTop() {
	var TimeoutCommand = "var HM_TopMenuToHide = HM_f_GetMenu('" + this.layerid + "'); if (HM_TopMenuToHide && HM_TopMenuToHide.hideSelf) HM_TopMenuToHide.hideSelf()";
	(HM_ClickKill) ? this.hideSelf() : (this.hideTimer = setTimeout(TimeoutCommand,HM_TopMilliSecondsVisible));
}

function HM_f_HideSelf() {
	this.hideTimer = null;
	if (HM_IsReloading) return;
	if (!this.isOn && !HM_UserOverMenu) this.showIt(false);
}

function HM_f_HideParents() {
	var TempMenu = this;
	while(TempMenu.hasParent) {
		TempMenu.showIt(false);
		TempMenu.parentMenu.isOn = false;        
// 5.1
		TempMenu.parentMenu.hasChildVisible=false;
		TempMenu = TempMenu.parentMenu;
	}
	TempMenu.hideTop();
}

function HM_f_HideChildren(callingitem,forced) {
	var TempMenu = this.visibleChild;
	while(TempMenu.hasChildVisible) {
		TempMenu.visibleChild.showIt(false);
		TempMenu.hasChildVisible = false;
		TempMenu = TempMenu.visibleChild;
	}

	if(forced || ((!this.isOn || !callingitem.hasMore || this.visibleChild != callingitem.child))) {
		this.visibleChild.showIt(false);
		this.hasChildVisible = false;
	}
}

function HM_f_PageClick() {
	if(HM_IsReloading) return;
	if (!HM_UserOverMenu && HM_CurrentMenu!=null && !HM_CurrentMenu.isOn) HM_f_HideAll();
}

function HM_f_EnableScrolling(topedge){
	if (!HM_FramesEnabled || HM_FramesNavFramePos != "top") {
		this.yPos = (topedge + HM_WindowPadding);
		var edgesOffset = (HM_WindowPadding * 2);
	} 
	else {
		this.yPos = topedge;
		var edgesOffset = HM_WindowPadding;
	}
	var WindowHeight = HM_MenusTarget.innerHeight;
	this.clip.height = (Math.max(WindowHeight,((HM_ScrollBarHeight*2)+HM_ScrollHeightMin)) - edgesOffset);
	if(!this.scrollbarsCreated) this.createScrollbars();
	this.checkScroll();
}

function HM_f_CreateScrollbars(){
	var BarWidthFull = this.clip.width;
	var BarWidth = (BarWidthFull - (HM_BorderWidth*2));
	var TopScrollElement = new Layer(BarWidthFull,this);
	with(TopScrollElement){
		top = 0;
		left = 0;
		clip.width = BarWidthFull;
		clip.height = HM_ScrollBarHeight;
		visibility = "hide";
		bgColor = this.tree.BorderColor;
	}
	var TopScrollElementLyr = new Layer(BarWidth,TopScrollElement);
	with(TopScrollElementLyr){
		top = HM_BorderWidth;
		left = HM_BorderWidth;
		clip.width = BarWidth;
		clip.height = HM_ScrollBarHeight - (HM_BorderWidth * 2);
		visibility = "inherit";
		bgColor = HM_ScrollBarColor;
		}

	var TopScrollElementImgLyr = new Layer(100,TopScrollElementLyr);
	with(TopScrollElementImgLyr){
		visibility = "inherit";
		top = (TopScrollElementLyr.clip.height - HM_ScrollImgHeight)/2;
		left = (BarWidth - HM_ScrollImgWidth)/2;
		document.write("<IMG VSPACE=0 HSPACE=0 SRC='" + HM_ScrollImgSrcTop +"'>");
		document.close();
	}

	var BotScrollElement = new Layer(BarWidthFull,this);
	with(BotScrollElement){
		top = 0;
		left = 0;
		clip.width = BarWidthFull;
		clip.height = HM_ScrollBarHeight;
		visibility = "hide";
		bgColor = this.tree.BorderColor;
	}
	var BotScrollElementLyr = new Layer(BarWidth,BotScrollElement);
	with(BotScrollElementLyr){
		top = HM_BorderWidth;
		left = HM_BorderWidth;
		clip.width = BarWidth;
		clip.height = HM_ScrollBarHeight - (HM_BorderWidth * 2);
		visibility = "inherit";
		bgColor = HM_ScrollBarColor;
	}

	var BotScrollElementImgLyr = new Layer(100,BotScrollElementLyr);
	with(BotScrollElementImgLyr){
		visibility = "inherit";
		top = (BotScrollElementLyr.clip.height - HM_ScrollImgHeight)/2;
		left = (BarWidth - HM_ScrollImgWidth)/2;
		document.write("<IMG VSPACE=0 HSPACE=0 SRC='" + HM_ScrollImgSrcBot +"'>");
		document.close();
	}

	TopScrollElement.menu = this;
	this.scrollbarTop = TopScrollElement;

	BotScrollElement.menu = this;
	this.scrollbarBot = BotScrollElement;

	if(HM_ScrollOver) {
		this.scrollbarTop.onmouseover=HM_f_StartScrollUp;
		this.scrollbarTop.onmouseout=HM_f_StopScroll;
		this.scrollbarBot.onmouseover=HM_f_StartScrollDown;
		this.scrollbarBot.onmouseout=HM_f_StopScroll;
	}
	else {
		this.scrollbarTop.captureEvents(Event.MOUSEDOWN);
		this.scrollbarTop.onmousedown = HM_f_StartScrollUp;
		this.scrollbarBot.captureEvents(Event.MOUSEDOWN);
		this.scrollbarBot.onmousedown = HM_f_StartScrollDown;
	}

	this.scrollbarsCreated = true;
}

function HM_f_StartScrollUp() {
	HM_CurrentMenu=this.menu;
	HM_CurrentMenu.startScroll(true);
}

function HM_f_StartScrollDown() {
	HM_CurrentMenu=this.menu;
	HM_CurrentMenu.startScroll(false);
}

function HM_f_StartScroll(up){
	HM_f_StopScroll();
	if(HM_IsReloading) return false;
	if (this.hasChildVisible) this.hideChildren(false,true);
	HM_ScrollTimer = setInterval("HM_f_DoScroll(" + up + ")",HM_ScrollInterval);
	if(!HM_ScrollOver) {
		HM_MenusTarget.captureEvents(Event.MOUSEUP);
		HM_MenusTarget.onmouseup = HM_f_EndScrollCapture;
	}
	return false;
}

function HM_f_StopScroll(){
	clearInterval(HM_ScrollTimer);
	HM_ScrollTimer = null;
}

function HM_f_EndScrollCapture(){
	HM_f_StopScroll();
	HM_MenusTarget.releaseEvents(Event.MOUSEUP);
	HM_MenusTarget.onmouseup = null;
}

function HM_f_DoScroll(up){
	if(HM_IsReloading) {HM_f_EndScrollCapture(); return;}
	var ScrollEl = HM_CurrentMenu.scrollParent;
	if(up){
		ScrollEl.topCount +=10;
	}
	else{
		ScrollEl.topCount -=10;
	}
	HM_CurrentMenu.checkScroll();
}

function HM_f_CheckScroll(){
	var ScrollEl = this.scrollParent;
	var MenuHeight = this.clip.height;
	var ScrollHeight = ScrollEl.clip.height;
	var HeightDiff = (MenuHeight - ScrollHeight);
	var ScrollTopOffset = HM_ScrollBothBars ? (HM_ScrollBarHeight - HM_BorderWidth) : 0;

	if(!HeightDiff){
		this.scrollbarBot.visibility = "hide";
		this.scrollbarTop.visibility = "hide";
		ScrollEl.top = ScrollEl.topCount = 0;
		return;
	}
	if(HM_ScrollBothBars) HeightDiff -= (ScrollTopOffset*2);

	if(ScrollEl.topCount <= HeightDiff) {
		ScrollEl.topCount = HeightDiff;
		HM_f_StopScroll();
		this.scrollbarBot.top = (MenuHeight - HM_ScrollBarHeight);
		if(!HM_ScrollBothBars) this.scrollbarBot.visibility = "hide";
	}
	else {
		this.scrollbarBot.top = (MenuHeight - HM_ScrollBarHeight);
		this.scrollbarBot.visibility = "inherit";
		if(HM_ScrollBothBars) this.scrollbarTop.visibility = "inherit";
	}

	if(ScrollEl.topCount >= 0) {
		ScrollEl.topCount = 0;
		HM_f_StopScroll();
		if(!HM_ScrollBothBars)this.scrollbarTop.visibility = "hide";
	}
	else {
		this.scrollbarTop.visibility = "inherit";
		if(HM_ScrollBothBars) this.scrollbarBot.visibility = "inherit";
	}
	ScrollEl.top = ScrollEl.topCount + ScrollTopOffset;
}

popUp = HM_f_PopUp;
popDown = HM_f_PopDown;

HM_LoadElement = (HM_FramesEnabled) ? top : window;

// 5.1
if(HM_LoadElement.HM_LoadedOnce) {
	HM_LoadElement = window;
}
else HM_LoadElement.HM_LoadedOnce=true;

HM_f_OtherOnLoad = (HM_LoadElement.onload) ? HM_LoadElement.onload : function() {return true};
HM_LoadElement.onload = HM_f_FrameLoad;

function HM_f_ResizeHandler(){
	if (HM_MenusTarget.innerWidth == HM_OrigWidth && HM_MenusTarget.innerHeight == HM_OrigHeight) return;
	HM_Resized = true;
	HM_LoadElement.history.go(0);
}

function HM_f_HandleError(a,b,c){
	var ErrorMessage = arguments[0].toLowerCase();
	var AccessErrorFound = false;
	for (var i=0; i<HM_a_AccessErrors.length; i++) {
		if (ErrorMessage.indexOf(HM_a_AccessErrors[i])!=-1) {
			AccessErrorFound = true;
			HM_IsReloading = false;
			HM_BeingCreated = false;
// 5.1
			HM_AreLoaded = true;
			break;
		}
	}
	if(AccessErrorFound) return true;
	else return HM_f_OtherOnError(a,b,c);
}

HM_f_OtherOnError = (window.onerror) ? window.onerror : function() {return false};
window.onerror = HM_f_HandleError;

//end
